/**
 * 
 */
package com.demo2do.strawberry.entity.startup.fund;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.demo2do.strawberry.entity.startup.Startup;
import com.demo2do.strawberry.entity.user.profile.Profile;

/**
 * @author lute
 *
 */
@Entity
@Table(name = "fund_progress")
public class FundProgress {
	
	@Id
	@GeneratedValue
	private Long id;
	
	/** 投资时间 */
	private Date fundTime;
	
	/** 投资总额 */
	private BigDecimal sum;
	
	@Enumerated(EnumType.ORDINAL)
	private FundProgressType type;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = true)
	private Profile profile;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	private Startup startup;
	
	/** 是否为领投 */
	@Column(name = "is_leaded")
	private boolean leaded;
	
	/** 是否到帐*/
	@Column(name = "is_arrive")
	private boolean arrive;
	
	/**
	 * default constructor
	 */
	public FundProgress() {
		
	}
	
	/**
	 * @param sum
	 * @param leaded
	 * @param startup
	 */
	public FundProgress(BigDecimal sum, boolean leaded, Startup startup) {
		this.sum = sum;
		this.leaded = leaded;
		this.fundTime = new Date();
		this.startup = startup;
	}
	
	/**
	 * @param profile
	 * @param startup
	 * @return
	 */
	public FundProgress initialize(Profile profile, Startup startup) {
		this.profile = profile;
		this.startup = startup;
		this.type = FundProgressType.aliasOf(startup.getFundStatus());
		this.fundTime = new Date();
		this.arrive = false;
		return this;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @return the fundTime
	 */
	public Date getFundTime() {
		return fundTime;
	}

	/**
	 * @return the sum
	 */
	public BigDecimal getSum() {
		return sum;
	}
	
	/**
	 * @return the type
	 */
	public FundProgressType getType() {
		return type;
	}
	
	/**
	 * @return the profile
	 */
	public Profile getProfile() {
		return profile;
	}

	/**
	 * @return the startup
	 */
	public Startup getStartup() {
		return startup;
	}

	/**
	 * @return the leaded
	 */
	public boolean isLeaded() {
		return leaded;
	}
	
	/**
	 * @return the arrive
	 */
	public boolean isArrive() {
		return arrive;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @param fundTime the fundTime to set
	 */
	public void setFundTime(Date fundTime) {
		this.fundTime = fundTime;
	}

	/**
	 * @param sum the sum to set
	 */
	public void setSum(BigDecimal sum) {
		this.sum = sum;
	}
	
	/**
	 * @param type the type to set
	 */
	public void setType(FundProgressType type) {
		this.type = type;
	}
	
	/**
	 * @param profile the profile to set
	 */
	public void setProfile(Profile profile) {
		this.profile = profile;
	}

	/**
	 * @param startup the startup to set
	 */
	public void setStartup(Startup startup) {
		this.startup = startup;
	}

	/**
	 * @param leaded the leaded to set
	 */
	public void setLeaded(boolean leaded) {
		this.leaded = leaded;
	}
	
	/**
	 * @param arrive the arrive to set
	 */
	public void setArrive(boolean arrive) {
		this.arrive = arrive;
	}
	
}
